Skip to content

fix(android): missing listener instance try catch#110

Merged
gladiuscode merged 1 commit intomainfrom
fix/109-android-crash-caused-by-nulled-eventemitter
Apr 2, 2026
Merged

fix(android): missing listener instance try catch#110
gladiuscode merged 1 commit intomainfrom
fix/109-android-crash-caused-by-nulled-eventemitter

Conversation

@gladiuscode
Copy link
Copy Markdown
Owner

@gladiuscode gladiuscode commented Apr 2, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved stability of device orientation and lock state handling to prevent unexpected crashes.

@gladiuscode gladiuscode self-assigned this Apr 2, 2026
@gladiuscode gladiuscode added the bug Something isn't working label Apr 2, 2026
@gladiuscode gladiuscode linked an issue Apr 2, 2026 that may be closed by this pull request
3 tasks
@gladiuscode gladiuscode added the Android Android only label Apr 2, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

Added exception handling to three emitter methods in OrientationDirectorModule.kt by wrapping emitOnDeviceOrientationChanged, emitOnInterfaceOrientationChanged, and emitOnLockChanged calls in try/catch blocks that suppress exceptions, preventing crashes when no listener is active.

Changes

Cohort / File(s) Summary
Error Handling Wrapper
android/src/main/java/com/orientationdirector/OrientationDirectorModule.kt
Wrapped three emitter method calls in try/catch blocks to gracefully handle exceptions when listeners are unavailable, preventing runtime crashes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A hop, skip, and catch block away,
No crashes shall spoil the day!
When listeners drift out of sight,
Try-catch keeps the module bright ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly relates to the main change: adding try/catch blocks to handle missing listener instances on Android, preventing crashes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/109-android-crash-caused-by-nulled-eventemitter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@android/src/main/java/com/orientationdirector/OrientationDirectorModule.kt`:
- Around line 52-57: The current methods (e.g., sendOnDeviceOrientationChanged)
swallow all Exceptions around emitOnDeviceOrientationChanged; instead create a
small helper like ensureReactContextActive(reactContext) or
hasActiveCatalystInstance() that checks the ReactContext/CatalystInstance is
non-null and active, call that guard before invoking
emitOnDeviceOrientationChanged (and the other send* methods on lines 60-65 and
68-73), remove the broad try/catch blocks, and if you want visibility log only
unexpected errors (Log.e or processLogger.error) when the guard succeeds and an
emission actually throws — do not catch Exception broadly or hide failures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 75542ffa-7017-4e09-bda8-108e308590cc

📥 Commits

Reviewing files that changed from the base of the PR and between 2a7d334 and 29d33a1.

📒 Files selected for processing (1)
  • android/src/main/java/com/orientationdirector/OrientationDirectorModule.kt

@gladiuscode gladiuscode merged commit 678afad into main Apr 2, 2026
1 check passed
@gladiuscode gladiuscode deleted the fix/109-android-crash-caused-by-nulled-eventemitter branch April 2, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android Android only bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android crash caused by nulled eventEmitter

1 participant